package publish

import (
	"gitee.com/fierce_wolf/go-fox-edge-iot-common/iotRemote"
	"time"
)

func Scheduler() {
	go telemetryDVRScheduler()
	go telemetryDSRScheduler()
	go eventScheduler()

}

func telemetryDVRScheduler() {
	for true {
		time.Sleep(1 * time.Second)
		if iotRemote.Mqtt.Client == nil || !iotRemote.Mqtt.Client.IsConnected() {
			continue
		}

		telemetryDVR.publish()
	}
}

func telemetryDSRScheduler() {
	for true {
		time.Sleep(1 * time.Second)
		if iotRemote.Mqtt.Client == nil || !iotRemote.Mqtt.Client.IsConnected() {
			continue
		}

		telemetryDSR.publish()
	}
}

func eventScheduler() {
	for true {
		time.Sleep(1 * time.Second)
		if iotRemote.Mqtt.Client == nil || !iotRemote.Mqtt.Client.IsConnected() {
			continue
		}

		event.publish()
	}
}
